/**
 * Created with IntelliJ IDEA.
 * Description:类和对象
 */
class Cat{
    //成员变量
    public String name;
    public int age;
    public String color;
    //成员方法
    public void eat(){
        System.out.println(name + "正在吃猫粮");
    }
    public  void meow(){
        System.out.println(name + "正在喵喵叫");
    }
}
public class Test4 {
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.name = "富贵";
        cat.age = 2;
        cat.color = "黄色";
        System.out.println(cat.name);    //输出富贵
        System.out.println(cat.age);     //error
        System.out.println(cat.color);   //输出黄色
    }
    public static void main1(String[] args) {
       //成员变量不赋值时：
        /*Cat cat = new Cat();
        System.out.println(cat.name);
        System.out.println(cat.age);
        System.out.println(cat.color);*/
        Cat cat = new Cat();
        cat.name = "富贵";
        cat.age = 2;
        cat.color = "黄色";
        cat.eat();
        cat.meow();
        System.out.println(cat.name);
        System.out.println(cat.age);
        System.out.println(cat.color);
        System.out.println("=========");
        Cat cat1 = new Cat();
        cat1.name = "咪咪";
        cat1.age = 3;
        cat1.color = "黑色";
        cat1.eat();
        cat1.meow();
        System.out.println(cat1.name);
        System.out.println(cat1.age);
        System.out.println(cat1.color);

    }


}
